#include <iostream>
using namespace std;

void test1()
{
    int count = 0;
    for (int i = 0;i < 1000000;i++)
    {
        count--;
    }
}

void test2()
{
    int count = 0;
    for (int i = 0;i < 100000;i++)
    {
        count++;
    }
}

void test()
{
    test1();
    test2();
}

int main(void)
{
    test();

    cout << "test end" << endl;
    return 0;
}

/* 
sudo perf record -F 10000 -g -e cycles ./1_perf_性能分析_火焰图.out


sudo perf report
63.12%     0.00%  1_perf_性能<E5><88>  1_perf_性能分析_火焰图.out  [.] main                                                                                                                                                ◆
63.12%     0.00%  1_perf_性能<E5><88>  1_perf_性能分析_火焰图.out  [.] test()                                                                                                                                              ▒
46.18%    46.18%  1_perf_性能<E5><88>  1_perf_性能分析_火焰图.out  [.] test1()
16.94%    16.94%  1_perf_性能<E5><88>  1_perf_性能分析_火焰图.out  [.] test2()


sudo perf script | stackcollapse-perf.pl | flamegraph.pl > test.svg
浏览器打开test.svg即可
*/